<!-- HTML header for doxygen 1.8.3.1-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.3.1"/>
<title>Sifteo SDK: framebuffer.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="doxygen-style-overrides.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<center>
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Sifteo SDK" src="sdk_logo.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">
   &#160;<span id="projectnumber">v1.0.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
</center>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.3.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Home</span></a></li>
      <li><a href="pages.html"><span>Guides</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Reference</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Groups</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Pages</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_12cda917fe1d7c8b4e7d2501bb3636e4.html">sdk</a></li><li class="navelem"><a class="el" href="dir_2f23e30b638d6a5f333babd9a5d183e1.html">include</a></li><li class="navelem"><a class="el" href="dir_d5ace589187da7c83c1a7507ec9fbbef.html">sifteo</a></li><li class="navelem"><a class="el" href="dir_483499650334b406c1d3bbaf3a730f60.html">video</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">framebuffer.h</div>  </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="comment">/* -*- mode: C; c-basic-offset: 4; intent-tabs-mode: nil -*-</span></div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="comment"> * This file is part of the public interface to the Sifteo SDK.</span></div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="comment"> * Copyright &lt;c&gt; 2012 Sifteo, Inc. All rights reserved.</span></div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="comment"> */</span></div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;</div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="preprocessor">#pragma once</span></div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="preprocessor"></span><span class="preprocessor">#ifdef NOT_USERSPACE</span></div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="preprocessor"></span><span class="preprocessor">#   error This is a userspace-only header, not allowed by the current build.</span></div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="preprocessor"></span><span class="preprocessor">#endif</span></div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="preprocessor"></span></div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="preprocessor">#include &lt;sifteo/abi.h&gt;</span></div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="preprocessor">#include &lt;sifteo/macros.h&gt;</span></div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;<span class="preprocessor">#include &lt;sifteo/math.h&gt;</span></div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;</div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;<span class="keyword">namespace </span>Sifteo {</div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;</div>
<div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;<span class="keyword">template</span> &lt;<span class="keywordtype">unsigned</span> tW<span class="keywordtype">id</span>th, <span class="keywordtype">unsigned</span> tHeight, <span class="keywordtype">unsigned</span> tBitsPerPixel&gt;</div>
<div class="line"><a name="l00032"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_f_b_drawable.html">   32</a></span>&#160;<span class="keyword">struct </span><a class="code" href="struct_sifteo_1_1_f_b_drawable.html" title="A templatized VRAM accessor for drawing pixel graphics, in one of the cube&#39;s supported framebuffer dr...">FBDrawable</a> {</div>
<div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;    _SYSAttachedVideoBuffer sys;</div>
<div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;</div>
<div class="line"><a name="l00038"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_f_b_drawable.html#af83fc27f56780db6b43950084b3ffdc6">   38</a></span>&#160;    <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <a class="code" href="struct_sifteo_1_1_f_b_drawable.html#af83fc27f56780db6b43950084b3ffdc6" title="Return the width, in pixels, of this mode.">width</a>() {</div>
<div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;        <span class="keywordflow">return</span> tWidth;</div>
<div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;    }</div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;</div>
<div class="line"><a name="l00045"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_f_b_drawable.html#a915176f013210aef862fd3ce709c65c2">   45</a></span>&#160;    <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <a class="code" href="struct_sifteo_1_1_f_b_drawable.html#a915176f013210aef862fd3ce709c65c2" title="Return the height, in pixels, of this mode.">height</a>() {</div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;        <span class="keywordflow">return</span> tHeight;</div>
<div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;    }</div>
<div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;</div>
<div class="line"><a name="l00052"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_f_b_drawable.html#a1547550fc95d545e07a4fed11d6f7efc">   52</a></span>&#160;    <span class="keyword">static</span> <a class="code" href="struct_sifteo_1_1_vector2.html" title="Generalized two-element cartesian coordinate vector.">UInt2</a> <a class="code" href="struct_sifteo_1_1_f_b_drawable.html#a1547550fc95d545e07a4fed11d6f7efc" title="Return the size of this mode as a vector, in pixels.">size</a>() {</div>
<div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;        <span class="keywordflow">return</span> <a class="code" href="group__math.html#gab18c9af04a4a3a4a3c63656e40ab74ed" title="Create a Vector2, from a set of (x,y) coordinates.">vec</a>(tWidth, tHeight);</div>
<div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;    }</div>
<div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;</div>
<div class="line"><a name="l00060"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_f_b_drawable.html#acdcb38b2c758b9a65ba8cb8c861ec0c3">   60</a></span>&#160;    <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <a class="code" href="struct_sifteo_1_1_f_b_drawable.html#acdcb38b2c758b9a65ba8cb8c861ec0c3" title="Return the total number of colors this mode supports. This is equal to the number of colormap entries...">numColors</a>() {</div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;        <span class="keywordflow">return</span> 1 &lt;&lt; tBitsPerPixel;</div>
<div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;    }</div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;</div>
<div class="line"><a name="l00068"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_f_b_drawable.html#a3bff247149d32e5b033ccc6879097bd7">   68</a></span>&#160;    <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <a class="code" href="struct_sifteo_1_1_f_b_drawable.html#a3bff247149d32e5b033ccc6879097bd7" title="Returns the number of bits per pixel this framebuffer mode uses to store color indices.">bitsPerPixel</a>() {</div>
<div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;        <span class="keywordflow">return</span> tBitsPerPixel;</div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;    }</div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;</div>
<div class="line"><a name="l00075"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_f_b_drawable.html#aaf8025498a514106ab9f8d039c25f1b7">   75</a></span>&#160;    <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <a class="code" href="struct_sifteo_1_1_f_b_drawable.html#aaf8025498a514106ab9f8d039c25f1b7" title="Returns the size of this framebuffer&#39;s data, in bytes.">sizeInBytes</a>() {</div>
<div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;        <span class="keywordflow">return</span> tWidth * tHeight * tBitsPerPixel / 8;</div>
<div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;    }</div>
<div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;</div>
<div class="line"><a name="l00082"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_f_b_drawable.html#a8a69471556b755f3734c7db5039c4ee0">   82</a></span>&#160;    <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <a class="code" href="struct_sifteo_1_1_f_b_drawable.html#a8a69471556b755f3734c7db5039c4ee0" title="Returns the size of this framebuffer&#39;s data, in 16-bit words.">sizeInWords</a>() {</div>
<div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;        <span class="keywordflow">return</span> tWidth * tHeight * tBitsPerPixel / 16;</div>
<div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;    }</div>
<div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;</div>
<div class="line"><a name="l00095"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_f_b_drawable.html#a34a0c82c097d67ca34155eb15b08de25">   95</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="struct_sifteo_1_1_f_b_drawable.html#a34a0c82c097d67ca34155eb15b08de25" title="Plot a single pixel, at the specified location.">plot</a>(<a class="code" href="struct_sifteo_1_1_vector2.html" title="Generalized two-element cartesian coordinate vector.">UInt2</a> pos, <span class="keywordtype">unsigned</span> colorIndex)</div>
<div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;    {</div>
<div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;        <a class="code" href="group__macros.html#ga8a15779356736a0900a162442b1cda53" title="Runtime debug assertion.">ASSERT</a>(pos.<a class="code" href="struct_sifteo_1_1_vector2.html#a7362956454caca88012382934a1e94b9" title="Vector component X.">x</a> &lt;= tWidth &amp;&amp; pos.<a class="code" href="struct_sifteo_1_1_vector2.html#a6ef946409dc8f1fb0fb21f158ad12bec" title="Vector component Y.">y</a> &lt;= tHeight);</div>
<div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;</div>
<div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;        <span class="keyword">const</span> <span class="keywordtype">unsigned</span> pixelsPerByte = 8 / tBitsPerPixel;</div>
<div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;        <span class="keyword">const</span> <span class="keywordtype">unsigned</span> bytesPerLine = tWidth / pixelsPerByte;</div>
<div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;        <span class="keyword">const</span> <span class="keywordtype">unsigned</span> xByte = pos.<a class="code" href="struct_sifteo_1_1_vector2.html#a7362956454caca88012382934a1e94b9" title="Vector component X.">x</a> / pixelsPerByte;</div>
<div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;        <span class="keyword">const</span> <span class="keywordtype">unsigned</span> xBit = (pos.<a class="code" href="struct_sifteo_1_1_vector2.html#a7362956454caca88012382934a1e94b9" title="Vector component X.">x</a> % pixelsPerByte) * tBitsPerPixel;</div>
<div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;        <span class="keyword">const</span> <span class="keywordtype">unsigned</span> byteAddr = xByte + pos.<a class="code" href="struct_sifteo_1_1_vector2.html#a6ef946409dc8f1fb0fb21f158ad12bec" title="Vector component Y.">y</a> * bytesPerLine;</div>
<div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;        <span class="keyword">const</span> <span class="keywordtype">unsigned</span> pixelMask = ((1 &lt;&lt; tBitsPerPixel) - 1) &lt;&lt; xBit;</div>
<div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160;</div>
<div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160;        uint8_t byte = _SYS_vbuf_peekb(&amp;sys.vbuf, byteAddr);</div>
<div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;        byte &amp;= ~pixelMask;</div>
<div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;        byte |= colorIndex &lt;&lt; xBit;</div>
<div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;        _SYS_vbuf_pokeb(&amp;sys.vbuf, byteAddr, byte);</div>
<div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;    }</div>
<div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160;</div>
<div class="line"><a name="l00119"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_f_b_drawable.html#ac99e54a4a56186d19e036b5b95eb5207">  119</a></span>&#160;    <span class="keyword">static</span> uint16_t <a class="code" href="struct_sifteo_1_1_f_b_drawable.html#ac99e54a4a56186d19e036b5b95eb5207" title="Given a single color index, return an expanded version where the single color has been replicated to ...">expand16</a>(<span class="keywordtype">unsigned</span> colorIndex)</div>
<div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160;    {</div>
<div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160;        <span class="keywordflow">switch</span> (tBitsPerPixel) {</div>
<div class="line"><a name="l00122"></a><span class="lineno">  122</span>&#160;            <span class="keywordflow">case</span> 1:  <span class="keywordflow">return</span> colorIndex ? 0xFFFF : 0x0000;</div>
<div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160;            <span class="keywordflow">case</span> 2:  colorIndex |= colorIndex &lt;&lt; 2;</div>
<div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160;            <span class="keywordflow">case</span> 4:  colorIndex |= colorIndex &lt;&lt; 4;</div>
<div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;            <span class="keywordflow">case</span> 8:  colorIndex |= colorIndex &lt;&lt; 8;</div>
<div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160;            <span class="keywordflow">case</span> 16: <span class="keywordflow">return</span> colorIndex;</div>
<div class="line"><a name="l00127"></a><span class="lineno">  127</span>&#160;            <span class="keywordflow">default</span>: <a class="code" href="group__macros.html#ga8a15779356736a0900a162442b1cda53" title="Runtime debug assertion.">ASSERT</a>(0);</div>
<div class="line"><a name="l00128"></a><span class="lineno">  128</span>&#160;        }</div>
<div class="line"><a name="l00129"></a><span class="lineno">  129</span>&#160;    }</div>
<div class="line"><a name="l00130"></a><span class="lineno">  130</span>&#160;</div>
<div class="line"><a name="l00137"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_f_b_drawable.html#ae5c2a146270320ed4731469e7b63fada">  137</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="struct_sifteo_1_1_f_b_drawable.html#ae5c2a146270320ed4731469e7b63fada" title="Plot a horizontal span of pixels, given the position of the leftmost pixel, and the number of pixels ...">span</a>(<a class="code" href="struct_sifteo_1_1_vector2.html" title="Generalized two-element cartesian coordinate vector.">UInt2</a> pos, <span class="keywordtype">unsigned</span> <a class="code" href="struct_sifteo_1_1_f_b_drawable.html#af83fc27f56780db6b43950084b3ffdc6" title="Return the width, in pixels, of this mode.">width</a>, <span class="keywordtype">unsigned</span> colorIndex)</div>
<div class="line"><a name="l00138"></a><span class="lineno">  138</span>&#160;    {</div>
<div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;        <a class="code" href="group__macros.html#ga8a15779356736a0900a162442b1cda53" title="Runtime debug assertion.">ASSERT</a>(pos.<a class="code" href="struct_sifteo_1_1_vector2.html#a7362956454caca88012382934a1e94b9" title="Vector component X.">x</a> &lt;= tWidth &amp;&amp; width &lt;= tWidth &amp;&amp;</div>
<div class="line"><a name="l00140"></a><span class="lineno">  140</span>&#160;            (pos.<a class="code" href="struct_sifteo_1_1_vector2.html#a7362956454caca88012382934a1e94b9" title="Vector component X.">x</a> + width) &lt;= tWidth &amp;&amp; pos.<a class="code" href="struct_sifteo_1_1_vector2.html#a6ef946409dc8f1fb0fb21f158ad12bec" title="Vector component Y.">y</a> &lt; tHeight);</div>
<div class="line"><a name="l00141"></a><span class="lineno">  141</span>&#160;</div>
<div class="line"><a name="l00142"></a><span class="lineno">  142</span>&#160;        <span class="keyword">const</span> <span class="keywordtype">unsigned</span> pixelsPerWord = 16 / tBitsPerPixel;</div>
<div class="line"><a name="l00143"></a><span class="lineno">  143</span>&#160;        <span class="keyword">const</span> <span class="keywordtype">unsigned</span> wordsPerLine = tWidth / pixelsPerWord;</div>
<div class="line"><a name="l00144"></a><span class="lineno">  144</span>&#160;        <span class="keyword">const</span> <span class="keywordtype">unsigned</span> colorWord = <a class="code" href="struct_sifteo_1_1_f_b_drawable.html#ac99e54a4a56186d19e036b5b95eb5207" title="Given a single color index, return an expanded version where the single color has been replicated to ...">expand16</a>(colorIndex);</div>
<div class="line"><a name="l00145"></a><span class="lineno">  145</span>&#160;</div>
<div class="line"><a name="l00146"></a><span class="lineno">  146</span>&#160;        <span class="comment">// Calculate a base address in words, and</span></div>
<div class="line"><a name="l00147"></a><span class="lineno">  147</span>&#160;        <span class="comment">// left/right boundaries relative to that in bits.</span></div>
<div class="line"><a name="l00148"></a><span class="lineno">  148</span>&#160;        <span class="keywordtype">unsigned</span> addr = pos.<a class="code" href="struct_sifteo_1_1_vector2.html#a7362956454caca88012382934a1e94b9" title="Vector component X.">x</a> / pixelsPerWord + pos.<a class="code" href="struct_sifteo_1_1_vector2.html#a6ef946409dc8f1fb0fb21f158ad12bec" title="Vector component Y.">y</a> * wordsPerLine;</div>
<div class="line"><a name="l00149"></a><span class="lineno">  149</span>&#160;        <span class="keywordtype">int</span> start = (pos.<a class="code" href="struct_sifteo_1_1_vector2.html#a7362956454caca88012382934a1e94b9" title="Vector component X.">x</a> % pixelsPerWord) * tBitsPerPixel;</div>
<div class="line"><a name="l00150"></a><span class="lineno">  150</span>&#160;        <span class="keywordtype">int</span> end = start + width * tBitsPerPixel;</div>
<div class="line"><a name="l00151"></a><span class="lineno">  151</span>&#160;</div>
<div class="line"><a name="l00152"></a><span class="lineno">  152</span>&#160;        <span class="keywordflow">while</span> (end &gt; 0) {</div>
<div class="line"><a name="l00153"></a><span class="lineno">  153</span>&#160;            <span class="keywordflow">if</span> (start &lt;= 0 &amp;&amp; end &gt;= 16) {</div>
<div class="line"><a name="l00154"></a><span class="lineno">  154</span>&#160;                <span class="comment">// A run of complete words</span></div>
<div class="line"><a name="l00155"></a><span class="lineno">  155</span>&#160;</div>
<div class="line"><a name="l00156"></a><span class="lineno">  156</span>&#160;                <span class="keywordtype">unsigned</span> count = end / 16;</div>
<div class="line"><a name="l00157"></a><span class="lineno">  157</span>&#160;                _SYS_vbuf_fill(&amp;sys.vbuf, addr, colorWord, count);</div>
<div class="line"><a name="l00158"></a><span class="lineno">  158</span>&#160;                addr += count;</div>
<div class="line"><a name="l00159"></a><span class="lineno">  159</span>&#160;                <span class="keywordtype">unsigned</span> bits = count * 16;</div>
<div class="line"><a name="l00160"></a><span class="lineno">  160</span>&#160;                start -= bits;</div>
<div class="line"><a name="l00161"></a><span class="lineno">  161</span>&#160;                end -= bits;</div>
<div class="line"><a name="l00162"></a><span class="lineno">  162</span>&#160;</div>
<div class="line"><a name="l00163"></a><span class="lineno">  163</span>&#160;            } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00164"></a><span class="lineno">  164</span>&#160;                <span class="comment">// One partial word. (The first, last or only word)</span></div>
<div class="line"><a name="l00165"></a><span class="lineno">  165</span>&#160;</div>
<div class="line"><a name="l00166"></a><span class="lineno">  166</span>&#160;                <span class="keywordtype">unsigned</span> mask = bitRange&lt;uint16_t&gt;(start, end);</div>
<div class="line"><a name="l00167"></a><span class="lineno">  167</span>&#160;                <span class="keywordtype">unsigned</span> word = _SYS_vbuf_peek(&amp;sys.vbuf, addr);</div>
<div class="line"><a name="l00168"></a><span class="lineno">  168</span>&#160;                word &amp;= ~mask;</div>
<div class="line"><a name="l00169"></a><span class="lineno">  169</span>&#160;                word |= colorWord &amp; mask;</div>
<div class="line"><a name="l00170"></a><span class="lineno">  170</span>&#160;                _SYS_vbuf_poke(&amp;sys.vbuf, addr, word);</div>
<div class="line"><a name="l00171"></a><span class="lineno">  171</span>&#160;                addr++;</div>
<div class="line"><a name="l00172"></a><span class="lineno">  172</span>&#160;                start -= 16;</div>
<div class="line"><a name="l00173"></a><span class="lineno">  173</span>&#160;                end -= 16;</div>
<div class="line"><a name="l00174"></a><span class="lineno">  174</span>&#160;            }</div>
<div class="line"><a name="l00175"></a><span class="lineno">  175</span>&#160;        }</div>
<div class="line"><a name="l00176"></a><span class="lineno">  176</span>&#160;    }</div>
<div class="line"><a name="l00177"></a><span class="lineno">  177</span>&#160;</div>
<div class="line"><a name="l00184"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_f_b_drawable.html#ab08c479269e11bf775109a6a17e2967c">  184</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="struct_sifteo_1_1_f_b_drawable.html#ab08c479269e11bf775109a6a17e2967c" title="Fill a rectangle of pixels, specified as a top-left corner location and a size.">fill</a>(<a class="code" href="struct_sifteo_1_1_vector2.html" title="Generalized two-element cartesian coordinate vector.">UInt2</a> topLeft, <a class="code" href="struct_sifteo_1_1_vector2.html" title="Generalized two-element cartesian coordinate vector.">UInt2</a> <a class="code" href="struct_sifteo_1_1_f_b_drawable.html#a1547550fc95d545e07a4fed11d6f7efc" title="Return the size of this mode as a vector, in pixels.">size</a>, <span class="keywordtype">unsigned</span> colorIndex)</div>
<div class="line"><a name="l00185"></a><span class="lineno">  185</span>&#160;    {</div>
<div class="line"><a name="l00186"></a><span class="lineno">  186</span>&#160;        <span class="keywordflow">while</span> (size.<a class="code" href="struct_sifteo_1_1_vector2.html#a6ef946409dc8f1fb0fb21f158ad12bec" title="Vector component Y.">y</a>) {</div>
<div class="line"><a name="l00187"></a><span class="lineno">  187</span>&#160;            <a class="code" href="struct_sifteo_1_1_f_b_drawable.html#ae5c2a146270320ed4731469e7b63fada" title="Plot a horizontal span of pixels, given the position of the leftmost pixel, and the number of pixels ...">span</a>(topLeft, size.<a class="code" href="struct_sifteo_1_1_vector2.html#a7362956454caca88012382934a1e94b9" title="Vector component X.">x</a>, colorIndex);</div>
<div class="line"><a name="l00188"></a><span class="lineno">  188</span>&#160;            size.<a class="code" href="struct_sifteo_1_1_vector2.html#a6ef946409dc8f1fb0fb21f158ad12bec" title="Vector component Y.">y</a>--;</div>
<div class="line"><a name="l00189"></a><span class="lineno">  189</span>&#160;            topLeft.<a class="code" href="struct_sifteo_1_1_vector2.html#a6ef946409dc8f1fb0fb21f158ad12bec" title="Vector component Y.">y</a>++;</div>
<div class="line"><a name="l00190"></a><span class="lineno">  190</span>&#160;        }</div>
<div class="line"><a name="l00191"></a><span class="lineno">  191</span>&#160;    }</div>
<div class="line"><a name="l00192"></a><span class="lineno">  192</span>&#160;</div>
<div class="line"><a name="l00196"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_f_b_drawable.html#a091ff8768148f17e7009fecff7f28017">  196</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="struct_sifteo_1_1_f_b_drawable.html#ab08c479269e11bf775109a6a17e2967c" title="Fill a rectangle of pixels, specified as a top-left corner location and a size.">fill</a>(<span class="keywordtype">unsigned</span> colorIndex)</div>
<div class="line"><a name="l00197"></a><span class="lineno">  197</span>&#160;    {</div>
<div class="line"><a name="l00198"></a><span class="lineno">  198</span>&#160;        _SYS_vbuf_fill(&amp;sys.vbuf, 0, <a class="code" href="struct_sifteo_1_1_f_b_drawable.html#ac99e54a4a56186d19e036b5b95eb5207" title="Given a single color index, return an expanded version where the single color has been replicated to ...">expand16</a>(colorIndex), <a class="code" href="struct_sifteo_1_1_f_b_drawable.html#a8a69471556b755f3734c7db5039c4ee0" title="Returns the size of this framebuffer&#39;s data, in 16-bit words.">sizeInWords</a>());</div>
<div class="line"><a name="l00199"></a><span class="lineno">  199</span>&#160;    }</div>
<div class="line"><a name="l00200"></a><span class="lineno">  200</span>&#160;</div>
<div class="line"><a name="l00207"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_f_b_drawable.html#a58e1235538a8cf8e0b18d6c78ee4bc2e">  207</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="struct_sifteo_1_1_f_b_drawable.html#a58e1235538a8cf8e0b18d6c78ee4bc2e" title="Draw a span of pixels from a packed-pixel bitmap, of the same color depth as this framebuffer mode...">bitmapSpan</a>(<a class="code" href="struct_sifteo_1_1_vector2.html" title="Generalized two-element cartesian coordinate vector.">UInt2</a> pos, <span class="keywordtype">unsigned</span> <a class="code" href="struct_sifteo_1_1_f_b_drawable.html#af83fc27f56780db6b43950084b3ffdc6" title="Return the width, in pixels, of this mode.">width</a>, <span class="keyword">const</span> uint8_t *data)</div>
<div class="line"><a name="l00208"></a><span class="lineno">  208</span>&#160;    {</div>
<div class="line"><a name="l00209"></a><span class="lineno">  209</span>&#160;        <a class="code" href="group__macros.html#ga8a15779356736a0900a162442b1cda53" title="Runtime debug assertion.">ASSERT</a>(pos.<a class="code" href="struct_sifteo_1_1_vector2.html#a7362956454caca88012382934a1e94b9" title="Vector component X.">x</a> &lt;= tWidth &amp;&amp; width &lt;= tWidth &amp;&amp;</div>
<div class="line"><a name="l00210"></a><span class="lineno">  210</span>&#160;            (pos.<a class="code" href="struct_sifteo_1_1_vector2.html#a7362956454caca88012382934a1e94b9" title="Vector component X.">x</a> + width) &lt;= tWidth &amp;&amp; pos.<a class="code" href="struct_sifteo_1_1_vector2.html#a6ef946409dc8f1fb0fb21f158ad12bec" title="Vector component Y.">y</a> &lt; tHeight);</div>
<div class="line"><a name="l00211"></a><span class="lineno">  211</span>&#160;</div>
<div class="line"><a name="l00212"></a><span class="lineno">  212</span>&#160;        <span class="keyword">const</span> <span class="keywordtype">unsigned</span> pixelsPerByte = 8 / tBitsPerPixel;</div>
<div class="line"><a name="l00213"></a><span class="lineno">  213</span>&#160;        <span class="keyword">const</span> <span class="keywordtype">unsigned</span> bytesPerLine = tWidth / pixelsPerByte;</div>
<div class="line"><a name="l00214"></a><span class="lineno">  214</span>&#160;</div>
<div class="line"><a name="l00215"></a><span class="lineno">  215</span>&#160;        <span class="comment">// Base address in bits</span></div>
<div class="line"><a name="l00216"></a><span class="lineno">  216</span>&#160;        <span class="keywordtype">unsigned</span> addr = pos.<a class="code" href="struct_sifteo_1_1_vector2.html#a7362956454caca88012382934a1e94b9" title="Vector component X.">x</a> / pixelsPerByte + pos.<a class="code" href="struct_sifteo_1_1_vector2.html#a6ef946409dc8f1fb0fb21f158ad12bec" title="Vector component Y.">y</a> * bytesPerLine;</div>
<div class="line"><a name="l00217"></a><span class="lineno">  217</span>&#160;</div>
<div class="line"><a name="l00218"></a><span class="lineno">  218</span>&#160;        <span class="comment">// Bitmap alignment</span></div>
<div class="line"><a name="l00219"></a><span class="lineno">  219</span>&#160;        <span class="keywordtype">unsigned</span> shift = (pos.<a class="code" href="struct_sifteo_1_1_vector2.html#a7362956454caca88012382934a1e94b9" title="Vector component X.">x</a> % pixelsPerByte) * tBitsPerPixel;</div>
<div class="line"><a name="l00220"></a><span class="lineno">  220</span>&#160;        <span class="keywordtype">unsigned</span> invShift = 8 - shift;</div>
<div class="line"><a name="l00221"></a><span class="lineno">  221</span>&#160;</div>
<div class="line"><a name="l00222"></a><span class="lineno">  222</span>&#160;        <span class="comment">// Initial mask range, in bits, relative to the base address</span></div>
<div class="line"><a name="l00223"></a><span class="lineno">  223</span>&#160;        <span class="keywordtype">int</span> start = shift;</div>
<div class="line"><a name="l00224"></a><span class="lineno">  224</span>&#160;        <span class="keywordtype">int</span> end = start + width * tBitsPerPixel;</div>
<div class="line"><a name="l00225"></a><span class="lineno">  225</span>&#160;</div>
<div class="line"><a name="l00226"></a><span class="lineno">  226</span>&#160;        <span class="keywordflow">while</span> (end &gt; 0) {</div>
<div class="line"><a name="l00227"></a><span class="lineno">  227</span>&#160;            <span class="comment">// One source byte at a time, splatted to either one or two</span></div>
<div class="line"><a name="l00228"></a><span class="lineno">  228</span>&#160;            <span class="comment">// destination bytes in VRAM.</span></div>
<div class="line"><a name="l00229"></a><span class="lineno">  229</span>&#160;</div>
<div class="line"><a name="l00230"></a><span class="lineno">  230</span>&#160;            uint8_t source = *data;</div>
<div class="line"><a name="l00231"></a><span class="lineno">  231</span>&#160;            data++;</div>
<div class="line"><a name="l00232"></a><span class="lineno">  232</span>&#160;</div>
<div class="line"><a name="l00233"></a><span class="lineno">  233</span>&#160;            <span class="comment">// First byte</span></div>
<div class="line"><a name="l00234"></a><span class="lineno">  234</span>&#160;            <span class="keywordtype">unsigned</span> mask = (0xFF &lt;&lt; shift) &amp; bitRange&lt;uint16_t&gt;(start, end);</div>
<div class="line"><a name="l00235"></a><span class="lineno">  235</span>&#160;            <span class="keywordtype">unsigned</span> byte = _SYS_vbuf_peekb(&amp;sys.vbuf, addr);</div>
<div class="line"><a name="l00236"></a><span class="lineno">  236</span>&#160;            byte &amp;= ~mask;</div>
<div class="line"><a name="l00237"></a><span class="lineno">  237</span>&#160;            byte |= (source &lt;&lt; shift) &amp; mask;</div>
<div class="line"><a name="l00238"></a><span class="lineno">  238</span>&#160;            _SYS_vbuf_pokeb(&amp;sys.vbuf, addr, byte);</div>
<div class="line"><a name="l00239"></a><span class="lineno">  239</span>&#160;</div>
<div class="line"><a name="l00240"></a><span class="lineno">  240</span>&#160;            addr++;</div>
<div class="line"><a name="l00241"></a><span class="lineno">  241</span>&#160;            start -= 8;</div>
<div class="line"><a name="l00242"></a><span class="lineno">  242</span>&#160;            end -= 8;</div>
<div class="line"><a name="l00243"></a><span class="lineno">  243</span>&#160;</div>
<div class="line"><a name="l00244"></a><span class="lineno">  244</span>&#160;            <span class="comment">// Optional second byte</span></div>
<div class="line"><a name="l00245"></a><span class="lineno">  245</span>&#160;            <span class="keywordflow">if</span> (shift) {</div>
<div class="line"><a name="l00246"></a><span class="lineno">  246</span>&#160;                <span class="keywordtype">unsigned</span> mask = (0xFF &gt;&gt; invShift) &amp; bitRange&lt;uint16_t&gt;(start, end);</div>
<div class="line"><a name="l00247"></a><span class="lineno">  247</span>&#160;                <span class="keywordtype">unsigned</span> byte = _SYS_vbuf_peekb(&amp;sys.vbuf, addr);</div>
<div class="line"><a name="l00248"></a><span class="lineno">  248</span>&#160;                byte &amp;= ~mask;</div>
<div class="line"><a name="l00249"></a><span class="lineno">  249</span>&#160;                byte |= (source &gt;&gt; invShift) &amp; mask;</div>
<div class="line"><a name="l00250"></a><span class="lineno">  250</span>&#160;                _SYS_vbuf_pokeb(&amp;sys.vbuf, addr, byte);</div>
<div class="line"><a name="l00251"></a><span class="lineno">  251</span>&#160;            }</div>
<div class="line"><a name="l00252"></a><span class="lineno">  252</span>&#160;        }</div>
<div class="line"><a name="l00253"></a><span class="lineno">  253</span>&#160;    }</div>
<div class="line"><a name="l00254"></a><span class="lineno">  254</span>&#160;</div>
<div class="line"><a name="l00267"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_f_b_drawable.html#ab119af6db15cef57b214817a64723076">  267</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="struct_sifteo_1_1_f_b_drawable.html#ab119af6db15cef57b214817a64723076" title="Draw a packed-pixel bitmap, of the same color depth as this framebuffer mode.">bitmap</a>(<a class="code" href="struct_sifteo_1_1_vector2.html" title="Generalized two-element cartesian coordinate vector.">UInt2</a> topLeft, <a class="code" href="struct_sifteo_1_1_vector2.html" title="Generalized two-element cartesian coordinate vector.">UInt2</a> <a class="code" href="struct_sifteo_1_1_f_b_drawable.html#a1547550fc95d545e07a4fed11d6f7efc" title="Return the size of this mode as a vector, in pixels.">size</a>, <span class="keyword">const</span> uint8_t *data, <span class="keywordtype">unsigned</span> stride)</div>
<div class="line"><a name="l00268"></a><span class="lineno">  268</span>&#160;    {</div>
<div class="line"><a name="l00269"></a><span class="lineno">  269</span>&#160;        <span class="keywordflow">while</span> (size.<a class="code" href="struct_sifteo_1_1_vector2.html#a6ef946409dc8f1fb0fb21f158ad12bec" title="Vector component Y.">y</a>) {</div>
<div class="line"><a name="l00270"></a><span class="lineno">  270</span>&#160;            <a class="code" href="struct_sifteo_1_1_f_b_drawable.html#a58e1235538a8cf8e0b18d6c78ee4bc2e" title="Draw a span of pixels from a packed-pixel bitmap, of the same color depth as this framebuffer mode...">bitmapSpan</a>(topLeft, size.<a class="code" href="struct_sifteo_1_1_vector2.html#a7362956454caca88012382934a1e94b9" title="Vector component X.">x</a>, data);</div>
<div class="line"><a name="l00271"></a><span class="lineno">  271</span>&#160;            size.<a class="code" href="struct_sifteo_1_1_vector2.html#a6ef946409dc8f1fb0fb21f158ad12bec" title="Vector component Y.">y</a>--;</div>
<div class="line"><a name="l00272"></a><span class="lineno">  272</span>&#160;            topLeft.<a class="code" href="struct_sifteo_1_1_vector2.html#a6ef946409dc8f1fb0fb21f158ad12bec" title="Vector component Y.">y</a>++;</div>
<div class="line"><a name="l00273"></a><span class="lineno">  273</span>&#160;            data += stride;</div>
<div class="line"><a name="l00274"></a><span class="lineno">  274</span>&#160;        }</div>
<div class="line"><a name="l00275"></a><span class="lineno">  275</span>&#160;    }</div>
<div class="line"><a name="l00276"></a><span class="lineno">  276</span>&#160;</div>
<div class="line"><a name="l00282"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_f_b_drawable.html#a0559c1b7816843faf37e33fad17a9615">  282</a></span>&#160;    <span class="keywordtype">void</span> <span class="keyword">set</span>(<span class="keyword">const</span> uint16_t *data) {</div>
<div class="line"><a name="l00283"></a><span class="lineno">  283</span>&#160;        _SYS_vbuf_write(&amp;sys.vbuf, 0, data, <a class="code" href="struct_sifteo_1_1_f_b_drawable.html#a8a69471556b755f3734c7db5039c4ee0" title="Returns the size of this framebuffer&#39;s data, in 16-bit words.">sizeInWords</a>());</div>
<div class="line"><a name="l00284"></a><span class="lineno">  284</span>&#160;    }</div>
<div class="line"><a name="l00285"></a><span class="lineno">  285</span>&#160;</div>
<div class="line"><a name="l00289"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_f_b_drawable.html#aa066ef40aa0dced13a5704ed904011bc">  289</a></span>&#160;    _SYSVideoBuffer &amp;<a class="code" href="struct_sifteo_1_1_f_b_drawable.html#aa066ef40aa0dced13a5704ed904011bc" title="Return the VideoBuffer associated with this drawable.">videoBuffer</a>() {</div>
<div class="line"><a name="l00290"></a><span class="lineno">  290</span>&#160;        <span class="keywordflow">return</span> sys.vbuf;</div>
<div class="line"><a name="l00291"></a><span class="lineno">  291</span>&#160;    }</div>
<div class="line"><a name="l00292"></a><span class="lineno">  292</span>&#160;</div>
<div class="line"><a name="l00296"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_f_b_drawable.html#abfe5b21e563e13d171fe7a575b72bd77">  296</a></span>&#160;    <a class="code" href="struct_sifteo_1_1_cube_i_d.html" title="A lightweight identifier for one Sifteo cube.">CubeID</a> <a class="code" href="struct_sifteo_1_1_f_b_drawable.html#abfe5b21e563e13d171fe7a575b72bd77" title="Return the CubeID associated with this drawable.">cube</a>()<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00297"></a><span class="lineno">  297</span>&#160;        <span class="keywordflow">return</span> sys.cube;</div>
<div class="line"><a name="l00298"></a><span class="lineno">  298</span>&#160;    }</div>
<div class="line"><a name="l00299"></a><span class="lineno">  299</span>&#160;};</div>
<div class="line"><a name="l00300"></a><span class="lineno">  300</span>&#160;</div>
<div class="line"><a name="l00301"></a><span class="lineno">  301</span>&#160;</div>
<div class="line"><a name="l00303"></a><span class="lineno"><a class="code" href="group__video.html#gae082a1d58a1d4ac09ed8b5cc948bc012">  303</a></span>&#160;<span class="keyword">typedef</span> <a class="code" href="struct_sifteo_1_1_f_b_drawable.html">FBDrawable&lt;32,32,4&gt;</a> <a class="code" href="group__video.html#gae082a1d58a1d4ac09ed8b5cc948bc012" title="Typedef for the FBDrawable instance used in FB32 mode.">FB32Drawable</a>;</div>
<div class="line"><a name="l00304"></a><span class="lineno">  304</span>&#160;</div>
<div class="line"><a name="l00306"></a><span class="lineno"><a class="code" href="group__video.html#ga4814a272383f823152dd22ec05fddac6">  306</a></span>&#160;<span class="keyword">typedef</span> <a class="code" href="struct_sifteo_1_1_f_b_drawable.html">FBDrawable&lt;64,64,1&gt;</a> <a class="code" href="group__video.html#ga4814a272383f823152dd22ec05fddac6" title="Typedef for the FBDrawable instance used in FB64 mode.">FB64Drawable</a>;</div>
<div class="line"><a name="l00307"></a><span class="lineno">  307</span>&#160;</div>
<div class="line"><a name="l00309"></a><span class="lineno"><a class="code" href="group__video.html#gad79361af9e54988266b4a6bd38d893ab">  309</a></span>&#160;<span class="keyword">typedef</span> <a class="code" href="struct_sifteo_1_1_f_b_drawable.html">FBDrawable&lt;128,48,1&gt;</a> <a class="code" href="group__video.html#gad79361af9e54988266b4a6bd38d893ab" title="Typedef for the FBDrawable instance used in FB128 mode.">FB128Drawable</a>;</div>
<div class="line"><a name="l00310"></a><span class="lineno">  310</span>&#160;</div>
<div class="line"><a name="l00311"></a><span class="lineno">  311</span>&#160;</div>
<div class="line"><a name="l00321"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_stamp_drawable.html">  321</a></span>&#160;<span class="keyword">struct </span><a class="code" href="struct_sifteo_1_1_stamp_drawable.html" title="A VRAM accessor for the STAMP mode, a special purpose 16-color framebuffer mode which supports color-...">StampDrawable</a> {</div>
<div class="line"><a name="l00322"></a><span class="lineno">  322</span>&#160;    _SYSAttachedVideoBuffer sys;</div>
<div class="line"><a name="l00323"></a><span class="lineno">  323</span>&#160;</div>
<div class="line"><a name="l00331"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_stamp_drawable.html#a0449fa5b91fce375dbdd2d319c41556b">  331</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="struct_sifteo_1_1_stamp_drawable.html#a0449fa5b91fce375dbdd2d319c41556b" title="Change the geometry of the framebuffer memory used by this stamp.">resizeFB</a>(<a class="code" href="struct_sifteo_1_1_vector2.html" title="Generalized two-element cartesian coordinate vector.">Int2</a> pixelSize) {</div>
<div class="line"><a name="l00332"></a><span class="lineno">  332</span>&#160;        <a class="code" href="group__macros.html#ga8a15779356736a0900a162442b1cda53" title="Runtime debug assertion.">ASSERT</a>((pixelSize.<a class="code" href="struct_sifteo_1_1_vector2.html#a7362956454caca88012382934a1e94b9" title="Vector component X.">x</a> &amp; 1) == 0 &amp;&amp;</div>
<div class="line"><a name="l00333"></a><span class="lineno">  333</span>&#160;            pixelSize.<a class="code" href="struct_sifteo_1_1_vector2.html#a7362956454caca88012382934a1e94b9" title="Vector component X.">x</a> * pixelSize.<a class="code" href="struct_sifteo_1_1_vector2.html#a6ef946409dc8f1fb0fb21f158ad12bec" title="Vector component Y.">y</a> &lt;= 1536 &amp;&amp;</div>
<div class="line"><a name="l00334"></a><span class="lineno">  334</span>&#160;            pixelSize.<a class="code" href="struct_sifteo_1_1_vector2.html#a7362956454caca88012382934a1e94b9" title="Vector component X.">x</a> &lt;= 128 &amp;&amp;</div>
<div class="line"><a name="l00335"></a><span class="lineno">  335</span>&#160;            pixelSize.<a class="code" href="struct_sifteo_1_1_vector2.html#a6ef946409dc8f1fb0fb21f158ad12bec" title="Vector component Y.">y</a> &lt;= 128);</div>
<div class="line"><a name="l00336"></a><span class="lineno">  336</span>&#160;    </div>
<div class="line"><a name="l00337"></a><span class="lineno">  337</span>&#160;        _SYS_vbuf_poke(&amp;sys.vbuf, <a class="code" href="group__macros.html#gafef9199621fafa1bd046611921ab061f">offsetof</a>(_SYSVideoRAM, stamp_pitch)/2,</div>
<div class="line"><a name="l00338"></a><span class="lineno">  338</span>&#160;            (pixelSize.<a class="code" href="struct_sifteo_1_1_vector2.html#a7362956454caca88012382934a1e94b9" title="Vector component X.">x</a> &gt;&gt; 1) | (pixelSize.<a class="code" href="struct_sifteo_1_1_vector2.html#a6ef946409dc8f1fb0fb21f158ad12bec" title="Vector component Y.">y</a> &lt;&lt; 8));</div>
<div class="line"><a name="l00339"></a><span class="lineno">  339</span>&#160;    }</div>
<div class="line"><a name="l00340"></a><span class="lineno">  340</span>&#160;</div>
<div class="line"><a name="l00351"></a><span class="lineno">  351</span>&#160;    <span class="keyword">template</span> &lt;<span class="keywordtype">unsigned</span> tW<span class="keywordtype">id</span>th, <span class="keywordtype">unsigned</span> tHeight&gt;</div>
<div class="line"><a name="l00352"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_stamp_drawable.html#add514b1cf9ffd803ca28ad7d83dd33b2">  352</a></span>&#160;    <a class="code" href="struct_sifteo_1_1_f_b_drawable.html" title="A templatized VRAM accessor for drawing pixel graphics, in one of the cube&#39;s supported framebuffer dr...">FBDrawable&lt;tWidth, tHeight, 4&gt;</a>&amp; <a class="code" href="struct_sifteo_1_1_stamp_drawable.html#add514b1cf9ffd803ca28ad7d83dd33b2" title="Obtain an FBDrawable accessor for the framebuffer memory, using the supplied framebuffer dimensions...">getFB</a>()</div>
<div class="line"><a name="l00353"></a><span class="lineno">  353</span>&#160;    {</div>
<div class="line"><a name="l00354"></a><span class="lineno">  354</span>&#160;        <span class="keyword">auto</span> &amp;fb = *<span class="keyword">reinterpret_cast&lt;</span><a class="code" href="struct_sifteo_1_1_f_b_drawable.html" title="A templatized VRAM accessor for drawing pixel graphics, in one of the cube&#39;s supported framebuffer dr...">FBDrawable&lt;tWidth, tHeight, 4&gt;</a>*<span class="keyword">&gt;</span>(<span class="keyword">this</span>);</div>
<div class="line"><a name="l00355"></a><span class="lineno">  355</span>&#160;        <a class="code" href="group__macros.html#ga8a15779356736a0900a162442b1cda53" title="Runtime debug assertion.">ASSERT</a>(&amp;fb.sys == &amp;sys);</div>
<div class="line"><a name="l00356"></a><span class="lineno">  356</span>&#160;        <span class="keywordflow">return</span> fb;</div>
<div class="line"><a name="l00357"></a><span class="lineno">  357</span>&#160;    }</div>
<div class="line"><a name="l00358"></a><span class="lineno">  358</span>&#160;</div>
<div class="line"><a name="l00368"></a><span class="lineno">  368</span>&#160;    <span class="keyword">template</span> &lt;<span class="keywordtype">unsigned</span> tW<span class="keywordtype">id</span>th, <span class="keywordtype">unsigned</span> tHeight&gt;</div>
<div class="line"><a name="l00369"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_stamp_drawable.html#a8018b8db9b929f78d2c5f35a2ab22070">  369</a></span>&#160;    <a class="code" href="struct_sifteo_1_1_f_b_drawable.html" title="A templatized VRAM accessor for drawing pixel graphics, in one of the cube&#39;s supported framebuffer dr...">FBDrawable&lt;tWidth, tHeight, 4&gt;</a>&amp; <a class="code" href="struct_sifteo_1_1_stamp_drawable.html#a8018b8db9b929f78d2c5f35a2ab22070" title="Obtain an FBDrawable accessor for the framebuffer memory, using the supplied framebuffer dimensions...">initFB</a>()</div>
<div class="line"><a name="l00370"></a><span class="lineno">  370</span>&#160;    {</div>
<div class="line"><a name="l00371"></a><span class="lineno">  371</span>&#160;        _SYS_finish();</div>
<div class="line"><a name="l00372"></a><span class="lineno">  372</span>&#160;        <a class="code" href="struct_sifteo_1_1_stamp_drawable.html#a0449fa5b91fce375dbdd2d319c41556b" title="Change the geometry of the framebuffer memory used by this stamp.">resizeFB</a>(<a class="code" href="group__math.html#gab18c9af04a4a3a4a3c63656e40ab74ed" title="Create a Vector2, from a set of (x,y) coordinates.">vec</a>(tWidth, tHeight));</div>
<div class="line"><a name="l00373"></a><span class="lineno">  373</span>&#160;        <span class="keywordflow">return</span> getFB&lt;tWidth, tHeight&gt;();</div>
<div class="line"><a name="l00374"></a><span class="lineno">  374</span>&#160;    }</div>
<div class="line"><a name="l00375"></a><span class="lineno">  375</span>&#160;    </div>
<div class="line"><a name="l00384"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_stamp_drawable.html#aaf94599ea8b43357db0af7a8fd9013a0">  384</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="struct_sifteo_1_1_stamp_drawable.html#aaf94599ea8b43357db0af7a8fd9013a0" title="Set the horizontal window. This is the mode-specific X-axis counterpart to VideoBuffer::setWindow().">setHWindow</a>(uint8_t firstColumn, uint8_t numColumns) {</div>
<div class="line"><a name="l00385"></a><span class="lineno">  385</span>&#160;        _SYS_vbuf_poke(&amp;sys.vbuf, <a class="code" href="group__macros.html#gafef9199621fafa1bd046611921ab061f">offsetof</a>(_SYSVideoRAM, stamp_x)/2,</div>
<div class="line"><a name="l00386"></a><span class="lineno">  386</span>&#160;            firstColumn | (numColumns &lt;&lt; 8));</div>
<div class="line"><a name="l00387"></a><span class="lineno">  387</span>&#160;    }</div>
<div class="line"><a name="l00388"></a><span class="lineno">  388</span>&#160;</div>
<div class="line"><a name="l00396"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_stamp_drawable.html#afc5290cac10e27ed0f4508d1a0a474b8">  396</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="struct_sifteo_1_1_stamp_drawable.html#afc5290cac10e27ed0f4508d1a0a474b8" title="Set both the horizontal and vertical windows, to define a 2D box of pixels that we&#39;ll draw into...">setBox</a>(<a class="code" href="struct_sifteo_1_1_vector2.html" title="Generalized two-element cartesian coordinate vector.">Int2</a> topLeft, <a class="code" href="struct_sifteo_1_1_vector2.html" title="Generalized two-element cartesian coordinate vector.">Int2</a> size) {</div>
<div class="line"><a name="l00397"></a><span class="lineno">  397</span>&#160;        _SYS_vbuf_poke(&amp;sys.vbuf, <a class="code" href="group__macros.html#gafef9199621fafa1bd046611921ab061f">offsetof</a>(_SYSVideoRAM, first_line)/2,</div>
<div class="line"><a name="l00398"></a><span class="lineno">  398</span>&#160;            topLeft.<a class="code" href="struct_sifteo_1_1_vector2.html#a6ef946409dc8f1fb0fb21f158ad12bec" title="Vector component Y.">y</a> | (size.<a class="code" href="struct_sifteo_1_1_vector2.html#a6ef946409dc8f1fb0fb21f158ad12bec" title="Vector component Y.">y</a> &lt;&lt; 8));</div>
<div class="line"><a name="l00399"></a><span class="lineno">  399</span>&#160;        <a class="code" href="struct_sifteo_1_1_stamp_drawable.html#aaf94599ea8b43357db0af7a8fd9013a0" title="Set the horizontal window. This is the mode-specific X-axis counterpart to VideoBuffer::setWindow().">setHWindow</a>(topLeft.<a class="code" href="struct_sifteo_1_1_vector2.html#a7362956454caca88012382934a1e94b9" title="Vector component X.">x</a>, size.<a class="code" href="struct_sifteo_1_1_vector2.html#a7362956454caca88012382934a1e94b9" title="Vector component X.">x</a>);</div>
<div class="line"><a name="l00400"></a><span class="lineno">  400</span>&#160;    }</div>
<div class="line"><a name="l00401"></a><span class="lineno">  401</span>&#160;</div>
<div class="line"><a name="l00408"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_stamp_drawable.html#a6097816a832cc6fe2b550241360cc370">  408</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="struct_sifteo_1_1_stamp_drawable.html#a6097816a832cc6fe2b550241360cc370" title="Set the palette index of the &quot;key&quot; color.">setKeyIndex</a>(<span class="keywordtype">unsigned</span> index) {</div>
<div class="line"><a name="l00409"></a><span class="lineno">  409</span>&#160;        _SYS_vbuf_pokeb(&amp;sys.vbuf, <a class="code" href="group__macros.html#gafef9199621fafa1bd046611921ab061f">offsetof</a>(_SYSVideoRAM, stamp_key), index);</div>
<div class="line"><a name="l00410"></a><span class="lineno">  410</span>&#160;    }</div>
<div class="line"><a name="l00411"></a><span class="lineno">  411</span>&#160;</div>
<div class="line"><a name="l00417"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_stamp_drawable.html#a1220be1ddf4a4864af99b76c415178c6">  417</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="struct_sifteo_1_1_stamp_drawable.html#a1220be1ddf4a4864af99b76c415178c6" title="Disable transparency.">disableKey</a>() {</div>
<div class="line"><a name="l00418"></a><span class="lineno">  418</span>&#160;        <a class="code" href="struct_sifteo_1_1_stamp_drawable.html#a6097816a832cc6fe2b550241360cc370" title="Set the palette index of the &quot;key&quot; color.">setKeyIndex</a>(16);</div>
<div class="line"><a name="l00419"></a><span class="lineno">  419</span>&#160;    }</div>
<div class="line"><a name="l00420"></a><span class="lineno">  420</span>&#160;</div>
<div class="line"><a name="l00424"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_stamp_drawable.html#aeecbae9359b834e1f287598f4f9c0f01">  424</a></span>&#160;    _SYSVideoBuffer &amp;<a class="code" href="struct_sifteo_1_1_stamp_drawable.html#aeecbae9359b834e1f287598f4f9c0f01" title="Return the VideoBuffer associated with this drawable.">videoBuffer</a>() {</div>
<div class="line"><a name="l00425"></a><span class="lineno">  425</span>&#160;        <span class="keywordflow">return</span> sys.vbuf;</div>
<div class="line"><a name="l00426"></a><span class="lineno">  426</span>&#160;    }</div>
<div class="line"><a name="l00427"></a><span class="lineno">  427</span>&#160;</div>
<div class="line"><a name="l00431"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_stamp_drawable.html#a18e3dafafaecb894c3a08ab20072a73d">  431</a></span>&#160;    <a class="code" href="struct_sifteo_1_1_cube_i_d.html" title="A lightweight identifier for one Sifteo cube.">CubeID</a> <a class="code" href="struct_sifteo_1_1_stamp_drawable.html#a18e3dafafaecb894c3a08ab20072a73d" title="Return the CubeID associated with this drawable.">cube</a>()<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00432"></a><span class="lineno">  432</span>&#160;        <span class="keywordflow">return</span> sys.cube;</div>
<div class="line"><a name="l00433"></a><span class="lineno">  433</span>&#160;    }</div>
<div class="line"><a name="l00434"></a><span class="lineno">  434</span>&#160;};</div>
<div class="line"><a name="l00435"></a><span class="lineno">  435</span>&#160;</div>
<div class="line"><a name="l00436"></a><span class="lineno">  436</span>&#160;</div>
<div class="line"><a name="l00441"></a><span class="lineno">  441</span>&#160;};  <span class="comment">// namespace Sifteo</span></div>
</div><!-- fragment --></div><!-- contents -->
<!-- HTML footer for doxygen 1.8.3.1-->
<!-- start footer part -->
    <hr class="footer"/>
    <address class="footer">
        <p><a href="http://sifteo.com">Sifteo</a> SDK v1.0.0 <small>(see <a href="https://developers.sifteo.com/sifteosdk">all versions</a>)</small></p>
        <p>Last updated Wed Mar 27 2013, by <a href="http://www.stack.nl/~dimitri/doxygen">Doxygen</a></p>
    </address>
</body>
</html>
